Timer
Detailed Description
The Timer class provides repetitive and single-shot timers. To use it, create a timer, bind its timeout event, and call start(). From then on, it will emit the timeout event at constant intervals.
Example for a one second (1000 millisecond) timer.
const timer = new Timer();
timer.bind('timeout', (): void => { });
timer.start(1000);
// or
const timer = new Timer();
timer.interval = 1000;
timer.bind('timeout', (): void => { });
timer.start();
You can set a timer to time out only once by setting the singleShot property.
const timer = new Timer();
timer.singleShot = true;
timer.bind('timeout', (): void => { });
timer.start(1000);
If the properties of a started timer are modified, call restart() to restart it.
...
timer.interval = 1000;
timer.start();
...
timer.interval = 500;
timer.restart();
Stops the timer with the stop() function.
...
timer.stop();